package com.openai.chatgpt.controller;

import com.openai.chatgpt.domain.AjaxResult;
import com.openai.chatgpt.service.ChatgptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * chatgpt控制器
 *
 * @author Amadeus
 * @date 2024/02/17
 */
@Tag(name = "ChatgptController", description = "chatgpt")
@RestController
@RequestMapping("/admin")
public class ChatgptController {

    @Autowired
    private ChatgptService chatgptService;

    @Operation(summary = "聊天", description = "聊天")
    @GetMapping(value = "/v1/chat/completions")
    public AjaxResult<String> chatCompletionApi(String content) {
        return AjaxResult.success(chatgptService.chatCompletion(content));
    }

    @Operation(summary = "官方推荐实践", description = "官方推荐实践-聊天")
    @GetMapping(value = "/v1/chat/recommended/completions")
    public AjaxResult<String> chatRecommendedCompletion(String content) {
        return AjaxResult.success(chatgptService.chatRecommendedCompletion(content));
    }
}
